#!/bin/bash

source /etc/etc2git/etc2git.conf
source /etc/etc2git/etc2git.d/*

HOSTNAME=`hostname`
DATE=`date`

SCRIPT=/etc/cron.d/etc2git

mkdir -p /Backup/$HOSTNAME$DIRTOBACKUP
cd /Backup/$HOSTNAME/$DIRTOBACKUP
touch README.md
cat /etc/*release* > README.md
echo `ip a` >> README.md
git add README.md

cp -r $DIRTOBACKUP* /Backup/$HOSTNAME$DIRTOBACKUP
rm -R /Backup/$HOSTNAME/etc/cups
cd /Backup/$HOSTNAME$DIRTOBACKUP
git init

mkdir -p /Backup/`hostname`/etc/Backup/
cp -R /Backup/scripts /Backup/`hostname`/etc/Backup/

git add .
git branch -m 'master'
git commit -m "$DATE"
git config user.email "$USEREMAIL"
git config user.name "$BACKUPER"
git config credential.helper store
git config --global credential.helper store

git remote add origin $PROTOCOL://$BACKUPER:$BACKUPERPASS@$GOGSHOST/$BACKUPER/$PREFIX$T$HOSTNAME.git
git add .
git commit -m "$DATE"
#git push
git push -f --set-upstream origin master
